package com.ruoyi.mp.domain;

import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import com.ruoyi.mp.api.domain.MpAccount;
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfList;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.ArrayList;
import java.util.List;

/**
 * 公众号客服对象 mp_kf
 *
 * @author ruoyi
 * @date 2024-11-11
 */
public class MpKf extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /**  */
    private Long id;

    /** 客服完整账号 */
    @Excel(name = "客服完整账号")
    private String kfAccount;


    /** 客服编号 */
    @Excel(name = "客服编号")
    private String kfId;

    /** 客服头像 */
    @Excel(name = "客服头像")
    private String kfHeadimgurl;

    /** 邀请的过期时间 */
    @Excel(name = "邀请的过期时间")
    private Long inviteExpireTime;

    /** 客服微信号 */
    @Excel(name = "客服微信号")
    private String kfWx;

    /** 0等待，1拒绝，2过期 */
    @Excel(name = "0等待，1拒绝，2过期")
    private String inviteStatus;

    /** 0离线，1在线 */
    @Excel(name = "0离线，1在线")
    private String status;

    /** 正在接待会话数 */
    @Excel(name = "正在接待会话数")
    private Integer acceptedCase;

    /** 客服昵称 */
    @Excel(name = "客服昵称")
    private String nickName;

    /** 公众号id */
    @Excel(name = "公众号id")
    private Long accountId;

    /** 公众号appId */
    @Excel(name = "公众号appId")
    private String appId;

    /** 租户id */
    @Excel(name = "租户id")
    private Long tenantId;

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getId()
    {
        return id;
    }
    public void setKfAccount(String kfAccount)
    {
        this.kfAccount = kfAccount;
    }

    public String getKfAccount()
    {
        return kfAccount;
    }
    public void setKfId(String kfId)
    {
        this.kfId = kfId;
    }

    public String getKfId()
    {
        return kfId;
    }
    public void setKfHeadimgurl(String kfHeadimgurl)
    {
        this.kfHeadimgurl = kfHeadimgurl;
    }

    public String getKfHeadimgurl()
    {
        return kfHeadimgurl;
    }
    public void setInviteExpireTime(Long inviteExpireTime)
    {
        this.inviteExpireTime = inviteExpireTime;
    }

    public Long getInviteExpireTime()
    {
        return inviteExpireTime;
    }
    public void setKfWx(String kfWx)
    {
        this.kfWx = kfWx;
    }

    public String getKfWx()
    {
        return kfWx;
    }
    public void setInviteStatus(String inviteStatus)
    {
        this.inviteStatus = inviteStatus;
    }

    public String getInviteStatus()
    {
        return inviteStatus;
    }
    public void setStatus(String status)
    {
        this.status = status;
    }

    public String getStatus()
    {
        return status;
    }
    public void setAcceptedCase(Integer acceptedCase)
    {
        this.acceptedCase = acceptedCase;
    }

    public Integer getAcceptedCase()
    {
        return acceptedCase;
    }
    public void setNickName(String nickName)
    {
        this.nickName = nickName;
    }

    public String getNickName()
    {
        return nickName;
    }
    public void setAccountId(Long accountId)
    {
        this.accountId = accountId;
    }

    public Long getAccountId()
    {
        return accountId;
    }
    public void setAppId(String appId)
    {
        this.appId = appId;
    }

    public String getAppId()
    {
        return appId;
    }
    public void setTenantId(Long tenantId)
    {
        this.tenantId = tenantId;
    }

    public Long getTenantId()
    {
        return tenantId;
    }

    public List<MpKf> convert(WxMpKfList wxMpKfList, MpAccount mpAccount) {
        List<MpKf> mpKfList = new ArrayList<>();
        for (int i=0;i<wxMpKfList.getKfList().size();i++){
            MpKf mpKf = new MpKf();
            mpKf.setKfAccount(wxMpKfList.getKfList().get(0).getAccount());
            mpKf.setKfHeadimgurl(wxMpKfList.getKfList().get(0).getHeadImgUrl());
            mpKf.setKfId(wxMpKfList.getKfList().get(0).getId());
            mpKf.setNickName(wxMpKfList.getKfList().get(0).getNick());
            mpKf.setKfWx(wxMpKfList.getKfList().get(0).getWxAccount());
            mpKf.setInviteExpireTime(wxMpKfList.getKfList().get(0).getInviteExpireTime());
            mpKf.setInviteStatus(wxMpKfList.getKfList().get(0).getInviteStatus());
            mpKf.setAcceptedCase(wxMpKfList.getKfList().get(0).getAcceptedCase());
            mpKf.setAppId(mpAccount.getAppId());
            mpKf.setAccountId(mpAccount.getId());
            mpKfList.add(mpKf);
        }
        return mpKfList;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("kfAccount", getKfAccount())
                .append("kfId", getKfId())
                .append("kfHeadimgurl", getKfHeadimgurl())
                .append("inviteExpireTime", getInviteExpireTime())
                .append("kfWx", getKfWx())
                .append("inviteStatus", getInviteStatus())
                .append("status", getStatus())
                .append("acceptedCase", getAcceptedCase())
                .append("nickName", getNickName())
                .append("createTime", getCreateTime())
                .append("updateTime", getUpdateTime())
                .append("createBy", getCreateBy())
                .append("updateBy", getUpdateBy())
                .append("accountId", getAccountId())
                .append("appId", getAppId())
                .append("tenantId", getTenantId())
                .toString();
    }
}
